package com.qidi.platform.ui;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.gateway.filter.factory.RequestRateLimiterGatewayFilterFactory;
import org.springframework.cloud.gateway.filter.ratelimit.RedisRateLimiter;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 包    名 ：com.qidi.platform.ui
 * 文 件 名 : RestTestController
 * 描    述 : TODO
 * 作    者 ：zhouchao超哥
 * 创建时间 ：2018/6/13 11:28
 * 版    本 ：1.0
 */
@RestController
@RequestMapping
public class RestTestController {


    private Logger logger = LoggerFactory.getLogger(this.getClass());


    @Autowired
    private WebClient.Builder webClientBuilder;

    private final   String url="http://qidi-platform-service/";

    @GetMapping("/{id}/accounts")
    public Mono<String> findByIdWithAccounts(@PathVariable("id") String id){

        Flux.range(1, 10000)
                .publishOn(Schedulers.parallel())
                .subscribe(System.out::println);

        logger.info("ss");

        Mono<String> accounts = webClientBuilder.build().get().uri(url+"customer/{customer}", id).retrieve().bodyToMono(String.class);
        return accounts;

    }
}
